package cp.remote.activity;

import cp.remote.R;
import cp.remote.config.KinectConfig;
import cp.remote.config.NetworkConfig;
import cp.remote.controller.Config;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;

public class Config_Activity extends Main_Activity {

    Config conf;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.config);
        // Set default Values for Textfields all Values are in NetworkConfig
        ((EditText) findViewById(R.id.conf_txtIP)).setText(NetworkConfig.ip);
        ((EditText) findViewById(R.id.conf_txtRePort)).setText(String.format(
                "%d", NetworkConfig.remoteport));
        ((EditText) findViewById(R.id.conf_txtTaPort)).setText(String.format(
                "%d", NetworkConfig.taskport));
        ((EditText) findViewById(R.id.conf_txtKinectPort)).setText(String
                .format("%d", NetworkConfig.kinectport));
        ((EditText) findViewById(R.id.conf_txtKinectImgHeight)).setText(String
                .format("%d", KinectConfig.imgheight));
        ((EditText) findViewById(R.id.conf_txtKinectImgWidth)).setText(String
                .format("%d", KinectConfig.imgwidth));
        ((EditText)findViewById(R.id.conf_txtAdvanceTimeout)).setText(String.format("%d", NetworkConfig.timeout));
        // Set Listener to the elements
        conf = new Config();
        ((Button) findViewById(R.id.conf_cmbConnect)).setOnClickListener(conf);
        ((Button) findViewById(R.id.conf_cmbApply)).setOnClickListener(conf);
        ((Button) findViewById(R.id.conf_cmbDisconnect))
                .setOnClickListener(conf);
        ((CheckBox) findViewById(R.id.cbKinectImage)).setOnClickListener(conf);
        ((CheckBox) findViewById(R.id.conf_cbAdvance)).setOnClickListener(conf);
    }
    
    @Override
    public void onStart(){
    	super.onStart();
        conf.setActivity(this);
    }
    
    @Override
    public void onResume(){
        super.onResume();
    }

    @Override
    public void customStop() {    }

    @Override
    public void setStateText(String text) {
        ((EditText)findViewById(R.id.conf_textarea_progress)).append(text +"\n");
    }
}
